const path = require("path");
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
module.exports = {
    publicPath: process.env.NODE_ENV === 'production' ? '././' : './',
    outputDir: "dist/wmsj-pc/",
    assetsDir: "./static",
    productionSourceMap: false,
    parallel: false,
    lintOnSave: false,
    pluginOptions: {
        "style-resources-loader": {
            preProcessor: "less",
            patterns: [
                path.resolve(__dirname, "./src/assets/css/variable.less")
            ]
        }
    },
    chainWebpack: config => {
        const oneOfsMap = config.module.rule('less').oneOfs.store
        oneOfsMap.forEach(item => {
            item
                .use('sass-resources-loader')
                .loader('sass-resources-loader')
                .options({
                    // 这里填入你的样式文件地址
                    resources: './src/assets/css/variable.less'
                })
                .end()
        })
    },
    devServer: {
        proxy: {
            '/chengxin': {
                target: 'https://internationcxapi.mpcheshi.com/chengxin',
                changeOrigin: true,
                ws: false,
                pathRewrite: {
                    '^/chengxin': ''
                }
            },
        },
        // https: true,
        overlay: {
            warnings: true,
            errors: true,
        },
    },
    configureWebpack: {
        plugins: [
            // new UglifyJsPlugin({
            //     uglifyOptions: {
            //         compress: {
            //             drop_console: true,
            //             drop_debugger: true,
            //             pure_funcs: ['console.log'] // 移除console
            //         },
            //         mangle: false,
            //         output: {
            //             beautify: true // 压缩注释
            //         }
            //     },
            //     sourceMap: true,
            //     parallel: true
            // })
        ],
    },

    css: {
        loaderOptions: {
            sass: {
                // javascriptEnabled: true,
            },
            less: {
                javascriptEnabled: true,
            },
            postcss: {
                plugins: [
                    require('postcss-pxtorem')({
                        rootValue: 108,
                        selectorBlackList: ['weui', 'mu'],
                        propList: ['*']
                    })
                ]
            }
        },
    },
    runtimeCompiler: true,
};


